package com.haiya.bridge.basic;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Client {
    public static void main(String[] args) throws IOException {
        BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("input abstraction name: ");
        String abstractionName = strin.readLine();
        System.out.println("input implementor name: ");
        String implName = strin.readLine();

        Abstraction abstraction = null;
        Implementor implementor = null;

        if (implName.equals("implementorA")) {
            implementor = new ConcreteImplementorA();
        } else if (implName.equals("implementorB")) {
            implementor = new ConcreteImplementorB();
        }

        if (implementor != null) {
            if (abstractionName.equals("abstractionA")) {
                abstraction = new RefinedAbstractionA(implementor);
            } else if (abstractionName.equals("abstractionB")) {
                abstraction = new RefinedAbstractionB(implementor);
            }
        }

        if (abstraction != null) {
            abstraction.operation();
        }
    }
}
